import { useEffect } from 'react';
import { useNavigate, Navigate } from 'react-router-dom';

type Props = { to: string, replace?: boolean, state?: object }

function Redirect({ to, replace, state }: Props): null {
    const navigate = useNavigate();

    useEffect(() => {
        navigate(to, { replace, state });
    });

    return null;
}

export default Redirect